Skip to content

Conversation

@baizmandesign
Copy link
Contributor

This pull request is in connection with #210.

When I ran the Behat tests for features/package-install.feature locally, a number of them failed. I'm not sure if that was just my computer's fault. If not, we may need to tweak some of the tests. (I wasn't able to troubleshoot why the tests failed locally. I know the tests are run in a temporary directory deep in /var/folders, but I wasn't sure how to run wp package commands that used an alternative composer.json, or where that alternative composer.json might live.)

@baizmandesign baizmandesign requested a review from a team as a code owner January 20, 2026 00:37
@github-actions
Copy link

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added command:package Related to 'package' command command:package-install Related to 'package install' command scope:testing Related to testing labels Jan 20, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @baizmandesign, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the wp package command by adding an is-installed subcommand. This new command provides a programmatic way to determine if a WP-CLI package is present, returning a clear exit status that can be utilized in scripts and automated workflows. The changes include updates to documentation, command registration, and thorough testing to ensure reliability and ease of use.

Highlights

  • New Subcommand: Introduced a new wp package is-installed <name> subcommand to check if a specific package is installed, returning an exit code of 0 for installed and 1 for uninstalled.
  • Documentation Update: The README.md file has been updated to include comprehensive documentation for the new is-installed subcommand, detailing its usage, options, and examples.
  • Composer Integration: The composer.json file was modified to register the newly added package is-installed subcommand, making it available within the WP-CLI ecosystem.
  • Test Coverage: Extensive Behat tests were added and updated in features/package-install.feature to validate the functionality of the is-installed subcommand across various installation and uninstallation scenarios.
  • Code Refinement: The src/Package_Command.php file was refactored to implement the public is_installed method and remove the now redundant private is_package_installed method, streamlining the package status check logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new wp package is-installed subcommand, which is a useful addition for scripting and checking the state of packages. The implementation is straightforward and includes comprehensive documentation and test coverage. My review includes a couple of suggestions to improve code conciseness and test maintainability.

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Package_Command.php 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@baizmandesign
Copy link
Contributor Author

@swissspidy Please see the comment attached to the pull request.

fzaninotto
"""

When I run `wp package is-installed yoast/wp-cli-faker`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you expect return code 1, you need to use "try" instead of "run"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great! So glad it was an easy fix. I'd cribbed the tests from the plugin is-installed command but apparently not that part of it.

@swissspidy
Copy link
Member

I wasn't able to troubleshoot why the tests failed locally. I know the tests are run in a temporary directory deep in /var/folders, but I wasn't sure how to run wp package commands that used an alternative composer.json, or where that alternative composer.json might live.)

When a test fails it will print the working directory like so:

001 Scenario: Install a package with an http package index url in package composer.json # features/package-install.feature:7
      When I run `wp package is-installed wp-cli/restful`                               # features/package-install.feature:49
        $ wp package is-installed wp-cli/restful

        cwd: /var/folders/44/hnwfklt963g865t5yf7yn5jw00lhhc/T/wp-cli-test-run--696f473689a729.89872360/
        run time: 0.25183796882629
        exit status: 1 (RuntimeException)

That's where you find all the files created during the test (such as composer.json). You can then run commands inside that directory to see what's going on (e.g. cd /var/folders/...; WP_CLI_PACKAGES_DIR=. wp package list) or do something like vendor/bin/wp --path=/var/folders/44/hnwfklt963g865t5yf7yn5jw00lhhc/T/wp-cli-test-run--696f473689a729.89872360/ package is-installed .... Using vendor/bin/wp ensures that you're really using the version from your branch with the new command.

Happy to elaborate on Slack if needed.

@swissspidy swissspidy changed the title Add is-installed subcommand. Add is-installed subcommand Jan 20, 2026
@swissspidy swissspidy added this to the 2.6.2 milestone Jan 20, 2026
@swissspidy swissspidy merged commit a198bca into wp-cli:main Jan 20, 2026
52 of 53 checks passed
@swissspidy swissspidy linked an issue Jan 20, 2026 that may be closed by this pull request
1 task
@baizmandesign baizmandesign deleted the feature/is-installed-command-2 branch January 20, 2026 11:33
@baizmandesign
Copy link
Contributor Author

Thanks for all of your help @swissspidy! I really appreciate it. :-)

@baizmandesign
Copy link
Contributor Author

@swissspidy Just wanted to thank you for providing guidance regarding troubleshooting the failed Behat tests. Your instructions are very clear; no need for a Slack consultation (though I appreciate the offer). Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:package Related to 'package' command command:package-install Related to 'package install' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: wp package is-installed subcommand

2 participants